/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.mldn.demo;

/**
 *
 * @author Administrator
 */
public class InterfaceCaseDemo04 {
    public static void main(String[] args) {
        Fruit f = null;
        f = FruitFactory.getInstance("apple");
        f.eat();
    }
}

class FruitFactory{
    public static Fruit getInstance(String className){
        Fruit f = null;
        if ("apple".equals(className)) {
            f = new Apple();
        }
        if ("orange".equals(className)) {
            f = new Orange();
        }
        return f;
    }
}